import request from '@/utils/request.js'
import { useTokenStore } from '@/stores/token.js';

// 文章分类列表查询
export const articleCategoryListService = () => {
    // const tokenStore = useTokenStore();
    // 在pinia中定义的响应式数据都不需要.value
    // return request.get('/category',{headers:{'Authorization':tokenStore.token}});
    return request.get('/category');

}

// 文章分类添加接口
export const articleCategoryAddService = (categoryData)=>{
    return request.post('/category',categoryData);
}

// 文章分类修改
export const articleCategoryUpdateService = (categoryData) =>{
    return request.put('/category',categoryData);
}

// 文章分类删除
export const articleCategoryDeleteService = (categoryId) =>{
    return request.delete('/category?id='+ categoryId);
}

// 文章列表查询
export const articleListService = (params)=> {
    // queryString的参数对象传递方式如下
    return request.get('/article',{params:params})
}

// 文章添加
export const articleAddService = (articleData) =>{
    return request.post('/article',articleData);
}

// 修改文章
export const articleUpdateService = (articleData) =>{
    return request.put('/article',articleData);
}

// 删除文章
export const articleDeleteService = (articleId) =>{
    return request.delete('/article?id='+ articleId);
}